home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / DFÜ / MacPPP Control 1.4 / Check The Mail < prev    next >
Text File  |  1994-10-06  |  2KB  |  73 lines

  1. --
  2. --    Check The Mail
  3. --    Copyright © 1994  Mark Alldritt
  4. --
  5. --    This simple script establishes a MacPPP connection, checks for new mail (and
  6. --    uploades queued mail), and finally shuts down the MacPPP connection.
  7. --
  8. --    Notes:
  9. --
  10. --    Requires MacPPP Control 1.1 or later and Eudora 1.4.2 or later
  11. --
  12. --
  13.  
  14. try
  15.     --
  16.     --    Get Eudora started so we don't have to wait for it once we've started the PPP
  17.     --    connection (time is money!).
  18.     --
  19.     tell application "Eudora" to launch
  20.     
  21.     --
  22.     --    Establish a PPP connection to the Mail Server
  23.     --
  24.     openPPP
  25.     
  26.     --
  27.     --    waste some time while the connection is established.  This is needed because MacPPP
  28.     --    operates asynchronously.
  29.     --
  30.     set i to 1
  31.     repeat while (i < 100 and not (PPPopened)) -- may need to increase 100 on fast Macs
  32.         set i to i + 1
  33.     end repeat
  34.     if not (PPPopened) then
  35.         error "MacPPP connection not opened"
  36.     end if
  37.     
  38.     --
  39.     --    Send queued messages and check for new mail
  40.     --
  41.     with timeout of 9999 seconds
  42.         tell application "Eudora"
  43.             connect with Send and Check
  44.         end tell
  45.     end timeout
  46.     
  47.     --
  48.     --    Shutdown the PPP connection
  49.     --
  50.     activate -- several activates are used to ensure the script is the foreground
  51.     activate -- process to avoid problems with closePPP when its called from the
  52.     activate -- background.
  53.     activate
  54.     closePPP
  55.     
  56. on error errorString
  57.     --
  58.     --    Something went wrong.  Let the user know, and offer to close the connection
  59.     --
  60.     
  61.     activate
  62.     if PPPopened then
  63.         display dialog "Can't check the mail (" & errorString & ").
  64.  
  65. Close MacPPP connection?" buttons {"Close", "Don't Close"} default button "Close" with icon caution
  66.         if button returned of the result = "Close" then
  67.             closePPP
  68.         end if
  69.     else
  70.         display dialog "Can't check the mail (" & errorString & ¬
  71.             ")." buttons "OK" default button "OK" with icon caution
  72.     end if
  73. end try